package com.hitqz.robot.driver.netty.protocol.message;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class KcMessageFactory {


    private final String license;

    // 默认泉州先进研究院的授权码 通过修改配置文件修改
    //  示例 泉州先进研究院: 76e846c55a9c2c4aa009a8e222d672af
    //  哈尔滨博实: a63f06e5d748534e8d3eafb2ca1fd08e
    //  科聪自用: 89dc0db105736d429c3261ddf54f066f
    //  pdh、制氢: 25338d3e34528f42962da17c5d9bc2be
    public KcMessageFactory(@Value("${robot.driver.kc.license:76e846c55a9c2c4aa009a8e222d672af}") String license) {
        this.license = license;
        log.info("kc license:{}",license);
    }

    public KcMessage createMessage(byte cmd, byte[] data) {
        return new KcMessage(cmd, data, license);
    }

    public KcMessage createMessage(byte cmd) {
        return new KcMessage(cmd, license);
    }

    public KcMessage createMessage(byte type, short sequence, byte cmd, byte executeCode, short dataLength, byte[] data) {
        return new KcMessage(type, sequence, cmd, executeCode, dataLength, data, license);
    }
}
